class CreateSalesOrders < ActiveRecord::Migration[5.1]
  def change
    create_table :sales_orders do |t|
      t.integer :firm_id, comment: '相关公司'
      t.integer :quotation_id, comment: '相关报价单'
      t.string :code, comment: '订单号'
      t.integer :sales_id, comment: '签单销售'
      t.datetime :sales_date, comment: '销售时间'
      t.integer :created_by, comment: '创建人'
      t.float :order_income, comment: '签单金额'
      t.boolean :full_paid, comment: '是否付清'
      t.boolean :full_invoiced, comment: '是否开好票'
      t.float :performance_money, comment: '业绩金额'
      t.integer :stage, comment: '订单阶段'

      t.timestamps
    end
    add_index :sales_orders, :firm_id
    add_index :sales_orders, :quotation_id
    add_index :sales_orders, :code
    add_index :sales_orders, :sales_id
    add_index :sales_orders, :sales_date
    add_index :sales_orders, :order_income
    add_index :sales_orders, :full_paid
    add_index :sales_orders, :full_invoiced
    add_index :sales_orders, :stage
  end
end
